<template>
<<<<<<< HEAD
  <div>
    1
  </div>
</template>

<script>
export default {

}
</script>

<style>

</style>
=======
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible"
  >
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      label-width="80px"
    >
      <el-form-item label="标签名称" prop="title">
        <el-input v-model="dataForm.title"></el-input>
      </el-form-item>
      <el-form-item label="状态" prop="prodCount">
        <el-radio-group v-model="dataForm.prodCount">
          <el-radio
            v-for="(type, index) in dataForm.typeList"
            :label="index"
            :key="index"
            >{{ type }}</el-radio
          >
        </el-radio-group>
      </el-form-item>
      <el-form-item label="列表样式" prop="isDefault">
        <el-radio-group v-model="dataForm.isDefault">
          <el-radio
            v-for="(type, index) in dataForm.iconList"
            :label="index"
            :key="index"
            >{{ type }}</el-radio
          >
        </el-radio-group>
      </el-form-item>

      <el-form-item v-if="dataForm.type !== 2" label="排序号" prop="seq">
        <el-input-number
          v-model="dataForm.seq"
          controls-position="right"
          :min="0"
          label="排序号"
        ></el-input-number>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { treeDataTranslate, idList } from "@/utils";
import Icon from "@/icons";
import { Debounce } from "@/utils/debounce";
export default {
  data() {
    var validateUrl = (rule, value, callback) => {
      if (this.dataForm.type === 1 && !/\S/.test(value)) {
        callback(new Error("菜单URL不能为空"));
      } else {
        callback();
      }
    };
    return {
      visible: false,
      dataForm: {
        id: '',
        status: 1,
        prodCount: 0,
        isDefault: 0,
        typeList: ["正常", "禁用"],
        seq: "",
        style: 1,
        title: "",

        iconList: ["一列一个", "一列两个", "一列三个"],
      },
      dataRule: {
        title: [
          { required: true, message: "菜单名称不能为空", trigger: "blur" },
          {
            pattern: /\s\S+|S+\s|\S/,
            message: "请输入正确的菜单名称",
            trigger: "blur",
          },
        ],
        url: [{ validator: validateUrl, trigger: "blur" }],
      },
      menuList: [],
      selectedMenu: [],
      menuListTreeProps: {
        value: "menuId",
        label: "name",
      },
    };
  },
  created() {
    this.iconList = Icon.getNameList();
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0;
      this.$http({
        url: this.$http.adornUrl("/prod/prodTag/page"),
        method: "get",
        params: this.$http.adornParams(),
      })
        .then(({ data }) => {
          this.menuList = treeDataTranslate(data, "id");
        })
        .then(() => {
          this.visible = true;
          this.$nextTick(() => {
            this.$refs["dataForm"].resetFields();
          });
        })
        .then(() => {
          if (this.dataForm.id) {
            // 修改
            this.$http({
              url: this.$http.adornUrl(
                `/prod/prodTag/page/${this.dataForm.id}`
              ),
              method: "get",
              params: this.$http.adornParams(),
            }).then(({ data }) => {
              this.dataForm.id = data.id;
              this.dataForm.createTime = data.createTime;
              this.dataForm.deleteTime = data.deleteTime;
              this.dataForm.shopId = data.shopId;
              this.dataForm.isDefault = data.isDefault;
              this.dataForm.prodCount = data.prodCount;
              this.dataForm.seq = data.seq;
              this.dataForm.status = data.status;
              this.dataForm.style = data.style;
              this.dataForm.title = data.title;
              this.dataForm.updateTime = data.updateTime;
              this.selectedMenu = idList(
                this.menuList,
                data.id,
                "id",
                "children"
              ).reverse();
            });
          } else {
            this.selectedMenu = [];
          }
        });
    },
    handleSelectMenuChange(val) {
      this.dataForm.parentId = val[val.length - 1];
    },
    // 图标选中
    iconActiveHandle(iconName) {
      this.dataForm.icon = iconName;
    },
    // 表单提交
    dataFormSubmit: Debounce(function () {
      this.$refs["dataForm"].validate((valid) => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl(`/prod/prodTag`),
            method: this.dataForm.id ? "put" : "post",
            data: this.$http.adornData({
              id: this.dataForm.id,
              createTime: this.dataForm.createTime,
              deleteTime: this.dataForm.deleteTime,
              isDefault: this.dataForm.isDefault,
              prodCount: this.dataForm.prodCount,
              seq: this.dataForm.seq,
              shopId: this.dataForm.shopId,
              status: this.dataForm.status,
              style: this.dataForm.style,

              title: this.dataForm.title,
              updateTime: this.dataForm.updateTime,
            }),
          }).then(({ data }) => {
            this.$message({
              message: "操作成功",
              type: "success",
              duration: 1500,
              onClose: () => {
                this.visible = false;
                this.$emit("refreshDataList");
              },
            });
          });
        }
      });
    }),
  },
};
</script>

<style lang="scss">
.mod-menu {
  .menu-list__input,
  .icon-list__input {
    > .el-input__inner {
      cursor: pointer;
    }
  }
  &__icon-popover {
    max-width: 420px;
  }
  &__icon-list {
    max-height: 180px;
    padding: 0;
    margin: -8px 0 0 -8px;
    > .el-button {
      padding: 8px;
      margin: 8px 0 0 8px;
      > span {
        display: inline-block;
        vertical-align: middle;
        width: 18px;
        height: 18px;
        font-size: 18px;
      }
    }
  }
  .icon-list__tips {
    font-size: 18px;
    text-align: center;
    color: #e6a23c;
    cursor: pointer;
  }
}
</style>
>>>>>>> origin/netbook
